package com.shaw.workrecord.exception;

import com.shaw.workrecord.entity.ResponseBean;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

@ControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(value = Exception.class)
    @ResponseBody
    public ResponseBean<Boolean> defaultErrorHandler(HttpServletRequest req, Exception e) throws Exception {
        return ResponseBean.failure(e.getLocalizedMessage());
    }
}
